package com.clas.liu.myapplication.view.fragment.impl;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.clas.liu.myapplication.model.entity.user.UserData;
import com.clas.liu.myapplication.view.util.SaveUtil;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.easeui.ui.EaseChatFragment;
import com.hyphenate.easeui.widget.EaseChatInputMenu;
import com.hyphenate.easeui.widget.chatrow.EaseCustomChatRowProvider;

/**
 * Created by liu on 2019/5/8.
 */

public class PersonChatFragment extends EaseChatFragment implements EaseChatFragment.EaseChatFragmentHelper {
    private UserData userData;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        setChatFragmentHelper(this);
         userData = SaveUtil.<UserData>getFromLocal(getActivity().getApplicationContext(), "user");
        return super.onCreateView(inflater, container, savedInstanceState);
    }
    @Override
    public void onSetMessageAttributes(EMMessage message) {

        // 通过扩展属性，将userPic和userName发送出去。
        String userPic = userData.getHead();
        if (!TextUtils.isEmpty(userPic)) {
            message.setAttribute("userPic", userPic);
        }
        String userName = userData.getName();
        if (!TextUtils.isEmpty(userName)) {
            message.setAttribute("userName", userName);
        }
    }

    @Override
    public void onEnterToChatDetails() {

    }

    @Override
    public void onAvatarClick(String username) {
        Toast.makeText(getActivity(),"头像被点击了"+username,Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onAvatarLongClick(String username) {

    }

    @Override
    public boolean onMessageBubbleClick(EMMessage message) {
        return false;
    }

    @Override
    public void onMessageBubbleLongClick(EMMessage message) {

    }

    @Override
    public boolean onExtendMenuItemClick(int itemId, View view) {
        return false;
    }

    @Override
    public EaseCustomChatRowProvider onSetCustomChatRowProvider() {
        return null;
    }
}
